﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
using System.Drawing;
using System.Windows.Forms;

namespace UCanSoft.PaintedSkin.Win32
{
    internal class Win32APIs
    {
        #region User32.dll 函数
        [DllImport("User32.dll", CharSet = CharSet.Auto)]
        public static extern Boolean AnimateWindow(IntPtr hwnd, UInt32 dwTime, UInt32 dwFlags);
        [DllImport("User32.dll", CharSet = CharSet.Auto)]
        public static extern IntPtr BeginPaint(IntPtr hwnd, out Win32DataTypes.PAINTSTRUCT lpPaint);
        [DllImport("User32.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
        public static extern Boolean BringWindowToTop(IntPtr hWnd);
        [DllImport("User32.dll", CharSet = CharSet.Auto)]
        public static extern IntPtr CallNextHookEx(IntPtr hhk, Int32 nCode, IntPtr wParam, IntPtr lParam);
        [DllImport("User32.dll", CharSet = CharSet.Auto)]
        public static extern IntPtr CallWindowProc(Win32DataTypes.WNDPROC lpPrevWndFunc, IntPtr hWnd, UInt32 Msg, IntPtr wParam, IntPtr lParam);
        [DllImport("User32.dll", CharSet = CharSet.Auto)]
        public static extern Boolean ClientToScreen(IntPtr hWnd, ref Win32DataTypes.POINT lpPoint);
        [DllImport("User32.dll", CharSet = CharSet.Auto)]
        public static extern Boolean ClientToScreen(IntPtr hWnd, ref Point lpPoint);
        [DllImport("User32.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
        public static extern IntPtr DefWindowProcA(IntPtr hWnd, UInt32 Msg, IntPtr wParam, IntPtr lParam);
        [DllImport("User32.dll", CharSet = CharSet.Auto)]
        public static extern IntPtr DispatchMessage(ref Win32DataTypes.MSG lpmsg);
        [DllImport("User32.dll", CharSet = CharSet.Auto)]
        public static extern IntPtr DispatchMessage(ref Message lpmsg);
        [DllImport("User32.dll", CharSet = CharSet.Auto)]
        public static extern Boolean DrawIconEx(IntPtr hdc, Int32 xLeft, Int32 yTop, IntPtr hIcon, Int32 cxWidth, Int32 cyWidth, UInt32 istepIfAniCur, IntPtr hbrFlickerFreeDraw, UInt32 diFlags);
        [DllImport("User32.dll", CharSet = CharSet.Auto)]
        public static extern Boolean EndPaint(IntPtr hWnd, ref Win32DataTypes.PAINTSTRUCT lpPaint);
        [DllImport("User32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
        public static extern Int32 FrameRect(IntPtr hDC, ref Win32DataTypes.RECT lprc, IntPtr hbr);
        [DllImport("User32.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
        public static extern IntPtr GetActiveWindow();
        [DllImport("User32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
        public static extern IntPtr GetCapture();
        [DllImport("User32.dll", CharSet = CharSet.Auto)]
        public static extern UInt32 GetClassLong(IntPtr hWnd, Int32 nIndex);
        [DllImport("User32.dll", CharSet = CharSet.Auto)]
        public static extern Int32 GetClassName(IntPtr hWnd, StringBuilder lpClassName, Int32 nMaxCount);
        [DllImport("User32.dll", CharSet = CharSet.Auto)]
        public static extern Boolean GetClientRect(IntPtr hWnd, ref Win32DataTypes.RECT lpRect);
        [DllImport("User32.dll", CharSet = CharSet.Auto)]
        public static extern Boolean GetClientRect(IntPtr hWnd, ref Rectangle lpRect);
        [DllImport("User32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
        public static extern Boolean GetComboBoxInfo(IntPtr hwndCombo, ref Win32DataTypes.COMBOBOXINFO cbi);
        [DllImport("User32.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
        public static extern Boolean GetCursorInfo(ref Win32DataTypes.CURSORINFO pci);
        [DllImport("User32.dll", CharSet = CharSet.Auto)]
        public static extern Boolean GetCursorPos(ref Point lpPoint);
        [DllImport("User32.dll", CharSet = CharSet.Auto)]
        public static extern IntPtr GetDC(IntPtr hWnd);
        [DllImport("User32.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
        public static extern Int32 GetDlgCtrlID(IntPtr hwndCtl);
        [DllImport("User32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
        public static extern IntPtr GetFocus();
        [DllImport("User32.dll", CharSet = CharSet.Auto)]
        public static extern ushort GetKeyState(Int32 virtKey);
        [DllImport("User32.dll", CharSet = CharSet.Auto)]
        public static extern Boolean GetMessage(ref Win32DataTypes.MSG lpMsg, IntPtr hWnd, UInt32 wMsgFilterMin, UInt32 wMsgFilterMax);
        [DllImport("User32.dll", CharSet = CharSet.Auto)]
        public static extern Boolean GetMessage(ref Message lpMsg, IntPtr hWnd, UInt32 wMsgFilterMin, UInt32 wMsgFilterMax);
        [DllImport("User32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
        public static extern Int32 GetMessagePos();
        [DllImport("User32.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
        public static extern IntPtr GetParent(IntPtr hWnd);
        [DllImport("User32.dll", CharSet = CharSet.Auto)]
        public static extern Boolean GetScrollBarInfo(IntPtr hwnd, UInt32 idObject, ref Win32DataTypes.SCROLLBARINFO psbi);
        [DllImport("User32.dll", CharSet = CharSet.Auto)]
        public static extern Boolean GetScrollInfo(IntPtr hwnd, Int32 fnBar, ref Win32DataTypes.SCROLLINFO lpsi);
        [DllImport("User32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
        public static extern Boolean GetScrollRange(IntPtr hWnd, Int32 nBar, ref Int32 lpMinPos, ref Int32 lpMaxPos);
        [DllImport("User32.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
        public static extern Int32 GetSysColor(Int32 nIndex);
        [DllImport("User32.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
        public static extern Int32 GetSystemMetrics(Int32 nIndex);
        [DllImport("User32.dll", CharSet = CharSet.Auto)]
        public static extern Boolean GetTitleBarInfo(IntPtr hwnd, ref Win32DataTypes.TITLEBARINFO pti);
        [DllImport("User32.dll", CharSet = CharSet.Auto)]
        public static extern IntPtr GetTopWindow(IntPtr hWnd);
        [DllImport("User32.dll", CharSet = CharSet.Auto)]
        public static extern IntPtr GetWindow(IntPtr hWnd, UInt32 wCmd);
        [DllImport("User32.dll", CharSet = CharSet.Auto)]
        public static extern IntPtr GetWindowDC(IntPtr hWnd);
        [DllImport("User32.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
        public static extern Boolean GetWindowInfo(IntPtr hwnd, ref Win32DataTypes.WINDOWINFO pwi);
        [DllImport("User32.dll", CharSet = CharSet.Auto)]
        public static extern UInt32 GetWindowLong(IntPtr hWnd, Int32 nIndex);
        [DllImport("User32.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
        public static extern Int32 GetWindowPlacement(IntPtr hWnd, ref Win32DataTypes.WINDOWPLACEMENT lpwndpl);
        [DllImport("User32.dll", CharSet = CharSet.Auto)]
        public static extern Boolean GetWindowRect(IntPtr hWnd, ref Win32DataTypes.RECT lpRect);
        [DllImport("User32.dll", CharSet = CharSet.Auto)]
        public static extern Boolean GetWindowRect(IntPtr hWnd, ref Rectangle lpRect);
        [DllImport("User32.dll", CharSet = CharSet.Auto)]
        public static extern Int32 GetWindowRgn(IntPtr hWnd, IntPtr hRgn);
        [DllImport("User32.dll", CharSet = CharSet.Ansi)]
        public static extern Int32 GetWindowText(IntPtr hWnd, StringBuilder lpString, Int32 nMaxCount);
        [DllImport("User32.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
        public static extern Int32 GetWindowTextLengthA(IntPtr hWnd);
        [DllImport("User32.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
        public static extern UInt32 GetWindowThreadProcessId(IntPtr hWnd, ref UInt32 lpdwProcessId);
        [DllImport("User32.dll", CharSet = CharSet.Auto)]
        public static extern Boolean HideCaret(IntPtr hWnd);
        [DllImport("User32.dll", CharSet = CharSet.Auto)]
        public static extern Boolean InvalidateRect(IntPtr hWnd, ref Win32DataTypes.RECT lpRect, Boolean bErase);
        [DllImport("User32.dll", CharSet = CharSet.Auto)]
        public static extern Boolean InvalidateRect(IntPtr hWnd, ref Win32DataTypes.RECT lpRect, Int32 bErase);
        [DllImport("User32.dll", CharSet = CharSet.Auto)]
        public static extern Boolean IsIconic(IntPtr hWnd);
        [DllImport("User32.dll", CharSet = CharSet.Auto)]
        public static extern Boolean IsWindowVisible(IntPtr hWnd);
        [DllImport("User32.dll", CharSet = CharSet.Auto)]
        public static extern Boolean IsZoomed(IntPtr hWnd);
        [DllImport("User32.dll", CharSet = CharSet.Auto)]
        public static extern IntPtr LoadCursor(IntPtr hInstance, UInt32 cursor);
        [DllImport("User32.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
        public static extern Int32 LoadStringA(Int32 hInstance, UInt32 uID, StringBuilder lpBuffer, Int32 nBufferMax);
        [DllImport("User32.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
        public static extern Int32 LoadStringW(Int32 hInstance, UInt32 uID, StringBuilder lpBuffer, Int32 nBufferMax);
        [DllImport("User32.dll", CharSet = CharSet.Auto)]
        public static extern Int32 MessageBox(IntPtr hWnd, String lpText, String lpCaption, UInt32 uType);
        [DllImport("User32.dll", CharSet = CharSet.Auto)]
        public static extern Boolean MoveWindow(IntPtr hWnd, Int32 x, Int32 y, Int32 width, Int32 height, Boolean repaint);
        [DllImport("User32.dll", CharSet = CharSet.Auto)]
        public static extern Boolean PeekMessage(ref Win32DataTypes.MSG msg, Int32 hWnd, UInt32 wFilterMin, UInt32 wFilterMax, UInt32 wFlag);
        [DllImport("User32.dll", CharSet = CharSet.Auto)]
        public static extern Boolean PeekMessage(ref Message lpMsg, IntPtr hWnd, UInt32 wMsgFilterMin, UInt32 wMsgFilterMax, UInt32 wRemoveMsg);
        [DllImport("User32.dll", CharSet = CharSet.Auto)]
        public static extern Boolean PostMessage(IntPtr hWnd, UInt32 Msg, IntPtr wParam, IntPtr lParam);
        [DllImport("User32.dll", CharSet = CharSet.Auto)]
        public static extern Boolean PostMessage(IntPtr hWnd, UInt32 Msg, UInt32 wParam, UInt32 lParam);
        [DllImport("User32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
        public static extern Boolean ReleaseCapture();
        [DllImport("User32.dll", CharSet = CharSet.Auto)]
        public static extern Int32 ReleaseDC(IntPtr hWnd, IntPtr hDC);
        [DllImport("User32.dll", CharSet = CharSet.Auto)]
        public static extern Boolean ScreenToClient(IntPtr hWnd, ref Win32DataTypes.POINT lpPoint);
        [DllImport("User32.dll", CharSet = CharSet.Auto)]
        public static extern Boolean ScreenToClient(IntPtr hWnd, ref Point lpPoint);
        [DllImport("User32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
        public static extern Boolean ScrollDC(IntPtr hDC, Int32 dx, Int32 dy, ref Win32DataTypes.RECT lprcScroll, ref Win32DataTypes.RECT lprcClip, IntPtr hrgnUpdate, out Win32DataTypes.RECT lprcUpdate);
        [DllImport("User32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
        public static extern Boolean ScrollWindow(IntPtr hWnd, Int32 XAmount, Int32 YAmount, IntPtr lpRect, IntPtr lpClipRect);
        [DllImport("User32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
        public static extern Int32 ScrollWindowEx(IntPtr hWnd, Int32 dx, Int32 dy, IntPtr prcScroll, IntPtr prcClip, IntPtr hrgnUpdate, IntPtr prcUpdate, UInt32 flags);
        [DllImport("User32.dll", CharSet = CharSet.Auto)]
        public static extern IntPtr SendMessage(IntPtr hWnd, UInt32 Msg, IntPtr wParam, IntPtr lParam);
        [DllImport("User32.dll", CharSet = CharSet.Auto)]
        public static extern IntPtr SendMessage(IntPtr hWnd, UInt32 Msg, UInt32 wParam, UInt32 lParam);
        [DllImport("User32.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
        public static extern IntPtr SetActiveWindow(IntPtr hWnd);
        [DllImport("User32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
        public static extern IntPtr SetCapture(IntPtr hWnd);
        [DllImport("User32.dll", CharSet = CharSet.Auto)]
        public static extern UInt32 SetClassLong(IntPtr hWnd, Int32 nIndex, UInt32 dwNewLong);
        [DllImport("User32.dll", CharSet = CharSet.Auto)]
        public static extern IntPtr SetCursor(IntPtr hCursor);
        [DllImport("User32.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
        public static extern Boolean SetLayeredWindowAttributes(IntPtr hwnd, Int32 crKey, byte bAlpha, Int32 dwFlags);
        [DllImport("User32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
        public static extern Int32 SetScrollInfo(IntPtr hwnd, Int32 fnBar, ref Win32DataTypes.SCROLLINFO lpsi, Boolean fRedraw);
        [DllImport("User32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
        public static extern Int32 SetScrollPos(IntPtr hWnd, Int32 nBar, Int32 nPos, Boolean bRedraw);
        [DllImport("User32.dll", CharSet = CharSet.Auto)]
        public static extern Win32DataTypes.WNDPROC SetWindowLong(IntPtr hWnd, Int32 nIndex, Win32DataTypes.WNDPROC dwNewLong);
        [DllImport("User32.DLL", CharSet = CharSet.Auto)]
        public static extern UInt32 SetWindowLong(IntPtr hWnd, Int32 nIndex, UInt32 dwNewLong);
        [DllImport("User32.dll", CharSet = CharSet.Auto)]
        public static extern Boolean SetWindowPos(IntPtr hWnd, Int32 hWndInsertAfter, Int32 X, Int32 Y, Int32 cx, Int32 cy, UInt32 uFlags);
        [DllImport("User32.dll", CharSet = CharSet.Auto)]
        public static extern Boolean SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, Int32 X, Int32 Y, Int32 cx, Int32 cy, UInt32 uFlags);
        [DllImport("User32.dll", CharSet = CharSet.Auto)]
        public static extern Int32 SetWindowRgn(IntPtr hWnd, IntPtr hRgn, Boolean bRedraw);
        [DllImport("User32.dll", CharSet = CharSet.Auto)]
        public static extern IntPtr SetWindowsHookEx(Int32 idHook, Win32DataTypes.HOOKPROC lpfn, Int32 hMod, Int32 dwThreadId);        
        [DllImport("User32.dll", CharSet = CharSet.Auto)]
        public static extern Boolean ShowCaret(IntPtr hWnd);
        [DllImport("User32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
        public static extern Boolean ShowScrollBar(IntPtr hWnd, Int32 wBar, Boolean bShow);
        [DllImport("User32.dll", CharSet = CharSet.Auto)]
        public static extern Int32 ShowWindow(IntPtr hWnd, short cmdShow);
        [DllImport("User32.dll", CharSet = CharSet.Auto)]
        public static extern Boolean SystemParametersInfoA(UInt32 uiAction, UInt32 uiParam, ref Win32DataTypes.NONCLIENTMETRICS pvParam, UInt32 fWinIni);
        [DllImport("User32.dll", CharSet = CharSet.Auto)]
        public static extern Boolean SystemParametersInfoA(UInt32 uiAction, UInt32 uiParam, ref Int32 bRetValue, UInt32 fWinINI);
        [DllImport("User32.dll", CharSet = CharSet.Auto)]
        public static extern Boolean TrackMouseEvent(ref Win32DataTypes.TRACKMOUSEEVENT tme);
        [DllImport("User32.dll", CharSet = CharSet.Auto)]
        public static extern Boolean TranslateMessage(ref Win32DataTypes.MSG lpMsg);
        [DllImport("User32.dll", CharSet = CharSet.Auto)]
        public static extern Boolean TranslateMessage(ref Message lpMsg);
        [DllImport("User32.dll", CharSet = CharSet.Auto)]
        public static extern Boolean UnhookWindowsHookEx(IntPtr hhk);
        [DllImport("User32.dll", CharSet = CharSet.Auto)]
        public static extern Boolean UpdateLayeredWindow(IntPtr hwnd, IntPtr hdcDst, ref Win32DataTypes.POINT pptDst, ref Win32DataTypes.SIZE psize, IntPtr hdcSrc, ref Win32DataTypes.POINT pptSrc, Int32 crKey, ref Win32DataTypes.BLENDFUNCTION pblend, Int32 dwFlags);
        [DllImport("User32.dll", CharSet = CharSet.Auto)]
        public static extern Boolean UpdateWindow(IntPtr hWnd);
        [DllImport("User32.dll", CharSet = CharSet.Auto)]
        public static extern Boolean WaitMessage();
        #endregion

        #region Kernel32.dll 函数
        [DllImport("Kernel32.DLL", CharSet = CharSet.Auto)]
        public static extern Boolean FreeLibrary(Int32 hModule);
        [DllImport("Kernel32.DLL", CharSet = CharSet.Auto)]
        public static extern IntPtr GetCurrentThread();
        [DllImport("Kernel32.DLL", CharSet = CharSet.Auto)]
        public static extern uint GetCurrentThreadId();
        [DllImport("Kernel32.DLL", CharSet = CharSet.Auto)]
        public static extern Int32 GetLastError();
        [DllImport("Kernel32.DLL", CharSet = CharSet.Auto)]
        public static extern Int32 LoadLibrary(String lpFileName);
        #endregion

        #region Gid32.dll 函数
        [DllImport("Gdi32.dll", CharSet = CharSet.Auto)]
        public static extern Boolean BitBlt(IntPtr hdcDest, Int32 nXDest, Int32 nYDest, Int32 nWidth, Int32 nHeight, IntPtr hdcSrc, Int32 nXSrc, Int32 nYSrc, uint dwRop);
        [DllImport("Gdi32.dll", CharSet = CharSet.Auto)]
        public static extern Int32 CombineRgn(IntPtr dest, IntPtr src1, IntPtr src2, Int32 flags);
        [DllImport("Gdi32.dll", CharSet = CharSet.Auto)]
        public static extern IntPtr CreateBrushIndirect(ref Win32DataTypes.LOGBRUSH brush);
        [DllImport("Gdi32.dll", CharSet = CharSet.Auto)]
        public static extern IntPtr CreateCompatibleDC(IntPtr hDC);
        [DllImport("Gdi32.dll", CharSet = CharSet.Auto)]
        public static extern IntPtr CreateFontIndirect(ref Win32DataTypes.LOGFONT lplf);
        [DllImport("Gdi32.DLL", CharSet = CharSet.Auto)]
        public static extern IntPtr CreateRectRgn(Int32 nLeftRect, Int32 nTopRect, Int32 nRightRect, Int32 nBottomRect);
        [DllImport("Gdi32.dll", CharSet = CharSet.Auto)]
        public static extern IntPtr CreateRectRgnIndirect(ref Win32DataTypes.RECT rect);
        [DllImport("Gdi32.DLL", CharSet = CharSet.Auto)]
        public static extern IntPtr CreateRoundRectRgn(Int32 nLeftRect, Int32 nTopRect, Int32 nRightRect, Int32 nBottomRect, Int32 nWidthEllipse, Int32 nHeightEllipse);
        [DllImport("Gdi32.dll", CharSet = CharSet.Auto)]
        public static extern Boolean DeleteDC(IntPtr hDC);
        [DllImport("Gdi32.DLL", CharSet = CharSet.Auto)]
        public static extern Boolean DeleteObject(IntPtr hObject);
        [DllImport("Gdi32.dll", CharSet = CharSet.Auto)]
        public static extern Int32 GetClipBox(IntPtr hDC, ref Win32DataTypes.RECT rectBox);
        [DllImport("Gdi32.dll", CharSet = CharSet.Auto)]
        public static extern Boolean PatBlt(IntPtr hDC, Int32 x, Int32 y, Int32 width, Int32 height, uint flags);
        [DllImport("Gdi32.dll", CharSet = CharSet.Auto)]
        public static extern Int32 SelectClipRgn(IntPtr hDC, IntPtr hRgn);
        [DllImport("Gdi32.dll", CharSet = CharSet.Auto)]
        public static extern IntPtr SelectObject(IntPtr hDC, IntPtr hObject);
        [DllImport("Gdi32.dll", CharSet = CharSet.Auto)]
        public static extern Int32 SetBkMode(IntPtr hdc, Int32 iBkMode);
        [DllImport("Gdi32.dll", CharSet = CharSet.Auto)]
        public static extern IntPtr SetTextColor(IntPtr hdc, IntPtr crColor);
        #endregion

    }
}
